<template>
	<view class="container">
		<uni-card :is-shadow="true" is-full style="background-color:  #F0EEEF;">
			<text class="uni-h6">题目上传器</text>
		</uni-card>
		
		<uni-section title="题目具体" type="line" style="background-color:  #F0EEEF;">
			<view class="example">
				<!-- 基础题目具体 -->
				<uni-forms ref="valiForm" :rules="rules" :model="valiFormData" labelWidth="80px">	
					<uni-forms-item label="A" required name="content1">
						<uni-easyinput v-model="valiFormData.content1" placeholder="请输入A"/>
					</uni-forms-item>
					<uni-forms-item label="B" required name="content2">
						<uni-easyinput v-model="valiFormData.content2" placeholder="请输入B"/>
					</uni-forms-item>
					<uni-forms-item label="C" required name="content3">
						<uni-easyinput v-model="valiFormData.content3" placeholder="请输入C"/>
					</uni-forms-item>
					<uni-forms-item label="D" required name="content4">
						<uni-easyinput v-model="valiFormData.content4" placeholder="请输入D"/>
					</uni-forms-item>
					
					
				
				</uni-forms>
				<button type="primary" @click="submit('valiForm')" style="background-color:  #90A674;border-radius: 50rpx;width: 60%;margin-bottom: 10rpx;">提交</button>
			</view>
		</uni-section>

	


	</view>
</template>

<script>
	export default {
		data() {
			return {
				insertId:0,
				ans:'',
			
				valiFormData:{
					
					content1: "",
					content2: "",
					content3: "",
					content4: ""
					
					
				},			
			}
		},
		mounted() {
			this.ans=uni.getStorageSync('ans');
			this.insertId=uni.getStorageSync('insertId');
			console.log(this.ans);
		},

	
		methods: {
	
		
			submit(ref) {
				
				this.$refs[ref].validate().then(res => {
					
					uni.request({
						url:"http://localhost:8888/setAnswer",
						method:"POST",
						data:{
							
							content1:this.valiFormData.content1,
							content2:this.valiFormData.content2,
							content3:this.valiFormData.content3,
							content4:this.valiFormData.content4,
							ans:this.ans,
							insertId:this.insertId
							
						},
							success(res){
								if(res.data.code==0 || res.data1.code==0 || res.data2.code==0 || res.data3.code==0){
									console.log("成功",res);
									uni.showToast({
									title: "上传成功"
								})
							}else{
								uni.showToast({
									title:"错误"
								})
							}
						}
					})
				}).catch(err => {
					console.log('err', err);
				})
			},
		}
	}
</script>

<style lang="scss">






</style>
